const config = require("./config")
const express = require("express")
    //const logger = require("morgan") 
const bodyParser = require('body-parser')
const app = express()
    //载入日志模块
    //app.use(logger("dev"))
    //app.use(express.static(__dirname + "/src"))

//post --> body.parser
app.use(bodyParser.urlencoded({ limit: '50mb', extended: false }))
app.use(bodyParser.json({ limit: '50mb' }))

//跨域模块
app.use(require('cors')())

//托管静态文件，让upload里的东西可以通过/访问
app.use('/uploads', express.static(__dirname + '/uploads'))

//导入路由
require('./routes/web')(app)

app.listen(config.port, () => {
    console.log("http://localhost:" + config.port)
})